package com.clayecloud.common.admin.controller;

import com.clayecloud.common.admin.services.RoleService;
import com.clayecloud.common.entity.Role;
import com.clayecloud.common.utils.MessageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author ClayeLink
 * @date 2022/3/16 22:29
 */
@RestController
@RequestMapping("/admin/role")
@Api(tags = "角色")
public class AdminRoleController {

    @Resource
    private RoleService roleService;

    @GetMapping("/selectAllForUser")
    @ApiOperation("查询所有角色")
    public MessageUtil selectAllForUser(){
        return roleService.selectAllForUser();
    }

    @PostMapping("/insert")
    @ApiOperation("增加角色")
    public MessageUtil insert(Role role){
        return roleService.insert(role);
    }

    @GetMapping("/delete")
    @ApiOperation("删除角色")
    public MessageUtil delete(Integer roleID){
        return roleService.delete(roleID);
    }

    @PutMapping("/update")
    @ApiOperation("更新角色")
    public MessageUtil update(Role role){
        System.out.println(role.toString());
        return roleService.update(role);
    }

    @GetMapping("/selectAll")
    @ApiOperation("查询所有角色")
    public MessageUtil selectAll(Integer size, Integer page){
        return roleService.selectAll(size, page);
    }

}
